﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Excel2Word
{
    public partial class FrmDefineExcelSource : Form
    {

        ExcelInputHelper inputHanlder ;
        public FrmDefineExcelSource()
        {
            InitializeComponent();
            this.TopMost = true;
            inputHanlder = ExcelInputHelper.GetInstance();
            dgvDefineSource.AutoGenerateColumns = false;

            dgvDefineSource.DataSource = AppStore.listEle;

        }



        /// <summary>
        /// 清空
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClear_Click(object sender, EventArgs e)
        {
            dgvDefineSource.Rows.Clear();

            //清空当前EXCEL表格中的底色和箭头

        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            this.Close();
            AppStore.mainForm.Show();
            AppStore.Serilize();
        }

        /// <summary>
        /// 重新绑定数据
        /// </summary>
        public void UpdateDataSource()
        {
            dgvDefineSource.DataSource = null;
            dgvDefineSource.DataSource = AppStore.listEle;
        }


        private void btnGetFromExcel_Click(object sender, EventArgs e)
        {

            inputHanlder.initInput(AppStore.targetWorkbook);
            this.Hide();

            if (rbRelative.Checked)
            {
                inputHanlder.setInputType(ExcelInputHelper.RELATIVE_TYPE);
            }
            else if(rbAbsolute.Checked)
            {
                inputHanlder.setInputType(ExcelInputHelper.ABSOLUTE_TYPE);
            }
            else
            {
                inputHanlder.setInputType(ExcelInputHelper.NAME_TYPE);
            }


            FrmExcelOperation feo = new FrmExcelOperation();
            AppStore.curOprateWindow = feo;
            feo.setParent(this);
            feo.Show();

            feo.SetCount(AppStore.listEle.Count);
        }

        //提交至数据库
        private void btnSubmit_Click(object sender, EventArgs e)
        {

        }
    }
}
